CMAKE_MINIMUM_REQUIRED(VERSION 3.17)

IF (NOT TARGET X264::H)
    ADD_LIBRARY(X264::H INTERFACE IMPORTED)
    TARGET_INCLUDE_DIRECTORIES(X264::H INTERFACE "${CMAKE_CURRENT_SOURCE_DIR}/windows/include")
ENDIF ()

IF (NOT TARGET X264::LIB)
    FIND_LIBRARY(X264_LIB NAMES libx264 PATHS ${CMAKE_CURRENT_SOURCE_DIR}/windows/lib NO_DEFAULT_PATH)
    ADD_LIBRARY(X264::LIB STATIC IMPORTED)
    SET_TARGET_PROPERTIES(X264::LIB PROPERTIES IMPORTED_LOCATION "${X264_LIB}")
ENDIF ()

IF (NOT TARGET LIBRARIES::X264)
    ADD_LIBRARY(LIBRARIES::X264 INTERFACE IMPORTED GLOBAL)
    TARGET_LINK_LIBRARIES(LIBRARIES::X264 INTERFACE
            X264::H
            X264::LIB)
ENDIF ()